package com.melhoramigo;

import com.melhoramigo.Utils.RoundImage;

import android.R;
import android.app.Fragment;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class ServicosFragment extends Fragment  {
	
    private ImageView btVet;
    private ImageView btCanil;
    private ImageView btDoadores;
    private ImageView btPetshop;
    private ImageView imagemCircular;
    RoundImage ri;
    Bitmap bm1;
    Bitmap bm;
    
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View rootView = inflater.inflate(com.melhoramigo.R.layout.fragment_servicos, container,
				false);
		
		btVet = (ImageView) rootView.findViewById(com.melhoramigo.R.id.btVet);
		btCanil = (ImageView) rootView.findViewById(com.melhoramigo.R.id.btCanil);
		btDoadores = (ImageView) rootView.findViewById(com.melhoramigo.R.id.btDoadores);
		btPetshop = (ImageView) rootView.findViewById(com.melhoramigo.R.id.btPetshop);
		imagemCircular = (ImageView) rootView.findViewById(com.melhoramigo.R.id.imagemCircular);
		
        bm1 = BitmapFactory.decodeResource(getResources(),com.melhoramigo.R.drawable.plus);
        bm = Bitmap.createScaledBitmap(bm1, 200, 200, true);
        ri = new RoundImage(bm);
        imagemCircular.setImageDrawable(ri);
		
        bm1 = BitmapFactory.decodeResource(getResources(),com.melhoramigo.R.drawable.btvet);
        bm = Bitmap.createScaledBitmap(bm1, 200, 200, true);
        ri = new RoundImage(bm);
        btVet.setImageDrawable(ri);
        
        bm1 = BitmapFactory.decodeResource(getResources(),com.melhoramigo.R.drawable.btcanil);
        bm = Bitmap.createScaledBitmap(bm1, 200, 200, true);
        ri = new RoundImage(bm);
        btCanil.setImageDrawable(ri);
        
        bm1 = BitmapFactory.decodeResource(getResources(),com.melhoramigo.R.drawable.btdoadores);
        bm = Bitmap.createScaledBitmap(bm1, 200, 200, true);
        ri = new RoundImage(bm);
        btDoadores.setImageDrawable(ri);
        
        bm1 = BitmapFactory.decodeResource(getResources(),com.melhoramigo.R.drawable.btpetshop);
        bm = Bitmap.createScaledBitmap(bm1, 100, 100, true);
        ri = new RoundImage(bm);
        btPetshop.setImageDrawable(ri);
        
        btVet.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				// Create new fragment and transaction
				Fragment newFragment = new VeterinariosFragment();
				android.app.FragmentTransaction transaction = getFragmentManager()
						.beginTransaction();

				// Replace whatever is in the fragment_container view with this
				// fragment,
				// and add the transaction to the back stack
				transaction.replace(com.melhoramigo.R.id.frame_container, newFragment);
				transaction.addToBackStack(null);

				// Commit the transaction
				transaction.commit();
			}
		});
        
        btPetshop.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				// Create new fragment and transaction
				Fragment newFragment = new PetshopFragment();
				android.app.FragmentTransaction transaction = getFragmentManager()
						.beginTransaction();

				// Replace whatever is in the fragment_container view with this
				// fragment,
				// and add the transaction to the back stack
				transaction.replace(com.melhoramigo.R.id.frame_container, newFragment);
				transaction.addToBackStack(null);

				// Commit the transaction
				transaction.commit();
			}
		});
        
        btDoadores.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				// Create new fragment and transaction
				Fragment newFragment = new DoadoresFragment();
				android.app.FragmentTransaction transaction = getFragmentManager()
						.beginTransaction();

				// Replace whatever is in the fragment_container view with this
				// fragment,
				// and add the transaction to the back stack
				transaction.replace(com.melhoramigo.R.id.frame_container, newFragment);
				transaction.addToBackStack(null);

				// Commit the transaction
				transaction.commit();
			}
		});
        
        btCanil.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				// Create new fragment and transaction
				Fragment newFragment = new CanisFragment();
				android.app.FragmentTransaction transaction = getFragmentManager()
						.beginTransaction();

				// Replace whatever is in the fragment_container view with this
				// fragment,
				// and add the transaction to the back stack
				transaction.replace(com.melhoramigo.R.id.frame_container, newFragment);
				transaction.addToBackStack(null);

				// Commit the transaction
				transaction.commit();
			}
		});

		return rootView;
	}
}
